function showPrice(obj){
    if($(obj).length){
        $(obj).val($(obj).val().replace(/[^0-9]/g, ''));
        if($(obj).val()!=''){
            $(obj).val(addCommasToNumber($(obj).val()));
        }
    }
}
function addCommasToNumber(numberStr){
    numberStr += '';
    x = numberStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + '.' + '$2');
    }
    return x1 + x2;
}

//open modal box
function openBox(id) {
    var Xwidth = $('#'+id).width();
    var Yheight = $('#'+id).height();

    var scrolledX, scrolledY;
    if( self.pageYOffset ) {
        scrolledX = self.pageXOffset;
        scrolledY = self.pageYOffset;
    } else if( document.documentElement && document.documentElement.scrollTop ) {
        scrolledX = document.documentElement.scrollLeft;
        scrolledY = document.documentElement.scrollTop;
    } else if( document.body ) {
        scrolledX = document.body.scrollLeft;
        scrolledY = document.body.scrollTop;
    }

    var centerX, centerY;
    if( self.innerHeight ) {
        centerX = self.innerWidth;
        centerY = self.innerHeight;
    } else if( document.documentElement && document.documentElement.clientHeight ) {
        centerX = document.documentElement.clientWidth;
        centerY = document.documentElement.clientHeight;
    } else if( document.body ) {
        centerX = document.body.clientWidth;
        centerY = document.body.clientHeight;
    }

    var leftOffset = scrolledX + (centerX - Xwidth) / 2;
    var topOffset = scrolledY + (centerY - Yheight) / 2;
    $('#'+id).css({
        "left": leftOffset + "px",
        "top": topOffset + "px",
        "position": "fixed"
    }).show();
    $('.black_overlay').css({
        "height": $(document).height() + "px"
    }).show();
}

function closeModalBox(){
    $('.white_content').hide();
    $('.black_overlay').hide();
}
function init_close_modal_box(){
    $("a.close").click(function(){
        if($(this).attr('lang')=='close_tip'){
            $(this).parent().parent('div:first').slideUp("fast");
        }else{
            closeModalBox()
        }
    });
}
function change_default_input_value(obj,default_text){
    if(obj.value==default_text){
        obj.value='';
    }else if(obj.value=='' || obj.value==' '){
        obj.value=default_text;
    }
}
